<template>
  <view class="work-container">
    <!-- 宫格组件 -->
    <view class="grid-body">
      <uni-grid :column="4" :showBorder="false" @change="changeGrid">
        <uni-grid-item :index="0">
          <view class="grid-item-box">
            <uni-icons type="notification-filled" size="45"></uni-icons>
            <text class="text">设备维修</text>
          </view>
        </uni-grid-item>
        <uni-grid-item :index="1">
          <view class="grid-item-box">
			<uni-icons  type="wallet" size="45"></uni-icons>
            <text class="text">生产工单</text>
          </view>
        </uni-grid-item>
        <uni-grid-item :index="2">
          <view class="grid-item-box">
            <uni-icons  type="calendar-filled" size="45"></uni-icons>
            <text class="text">报工单</text>
          </view>
        </uni-grid-item>
        <uni-grid-item :index="3">
          <view class="grid-item-box">
            <uni-icons  type="auth" size="45"></uni-icons>
            <text class="text">质检单</text>
          </view>
        </uni-grid-item>
        <uni-grid-item :index="4">
          <view class="grid-item-box">
            <uni-icons  type="upload" size="45"></uni-icons>
            <text class="text">仓库领料</text>
          </view>
        </uni-grid-item>
        <uni-grid-item :index="5">
          <view class="grid-item-box">
            <uni-icons  type="download-filled" size="45"></uni-icons>
            <text class="text">物料入库</text>
          </view>
        </uni-grid-item>
        <uni-grid-item :index="6">
          <view class="grid-item-box">
            <uni-icons  type="home" size="45"></uni-icons>
            <text class="text">库存查询</text>
          </view>
        </uni-grid-item>
		<uni-grid-item :index="7">
		  <view class="grid-item-box">
		    <uni-icons  type="email-filled" size="45"></uni-icons>
		    <text class="text">工资单</text>
		  </view>
		</uni-grid-item>
        <!-- 自定义图标 <uni-grid-item :index="7">
          <view class="grid-item-box">
            <uni-icons custom-prefix="iconfont" type="icon-icon-test" size="45"></uni-icons>
            <text class="text">工资单</text>
          </view>
        </uni-grid-item> -->
        <!-- <uni-grid-item>
          <view class="grid-item-box">
            <uni-icons type="more-filled" size="45"></uni-icons>
            <text class="text">更多功能</text>
          </view>
        </uni-grid-item> -->
      </uni-grid>
    </view>
	<uni-section title="数据统计(今日)" type="line" />
	<uni-card title="执行单据" style="margin-top: 0px;" >
		<uni-row class="resourceList-uni-row">
			<text  style="font-size: 16px;">生产工单:&nbsp;&nbsp;&nbsp;{{data.gongdan}}</text>
		</uni-row>
		
		<uni-row class="resourceList-uni-row">
			<uni-col :span="12" >
				<text style="font-size: 16px;">报工单:&nbsp;&nbsp;&nbsp;{{data.baogong}}</text>
			</uni-col>
			<uni-col :span="12">
				<text style="font-size: 16px;">质检单:&nbsp;&nbsp;&nbsp;{{data.zhijian}}</text>
			</uni-col>
		</uni-row>
		<uni-row class="resourceList-uni-row">
			<uni-col :span="12">
				<text style="font-size: 16px;">领料单:&nbsp;&nbsp;&nbsp;{{data.lingliao}}</text>
			</uni-col>
			<uni-col :span="12">
				<text style="font-size: 16px;">入库单:&nbsp;&nbsp;&nbsp;{{data.ruku}}</text>
			</uni-col>
		</uni-row>
	</uni-card>
	<uni-card title="生产质量" >
		<uni-row class="resourceList-uni-row">
			<text  style="font-size: 16px;">报工:&nbsp;&nbsp;&nbsp;{{data.pqResult.reportQ}}</text>
		</uni-row>
		<uni-row class="resourceList-uni-row">
			<uni-col :span="12">
				<text style="font-size: 16px;">合格:&nbsp;&nbsp;&nbsp;{{data.pqResult.qualifiedQ}}</text>
			</uni-col>
			<uni-col :span="12">
				<text style="font-size: 16px;">不合格:&nbsp;&nbsp;&nbsp;{{data.pqResult.unqualifiedQ}}</text>
			</uni-col>
		</uni-row>
		<text style="font-size: 16px;">合格率:&nbsp;&nbsp;&nbsp;{{data.pqResult.rate}}%</text>
	</uni-card>
	<uni-card title="工资总计" >
		<text style="font-size: 16px;">{{data.paySum}}&nbsp;&nbsp;&nbsp;元</text>
	</uni-card>
  </view>
</template>

<script>
	import {
		executeBillCount
	} from "@/api/work/work.js"
  export default {
    data() {
      return {
		queryParams:{},
        data:{
			gongdan:0,
			baogong:0,
			zhijian:0,
			lingliao:0,
			ruku:0,
			pqResult:{}
			
		}
      }
    },
	created() {
		this.initQueryParams();
		this.getExecuteBillCount();
	},
	activated() {
		this.getExecuteBillCount();
	},
    methods: {
      changeGrid(e) {
		  let index = e.detail.index;
		if(index===0){
			 this.$tab.navigateTo("/pages/equipment/repairOrder/index");
			return;
		}
		if(index===1){
			this.$tab.navigateTo("/pages/production/workOrder/index");
			return;
		}
		if(index===2){
			 this.$tab.navigateTo("/pages/production/report/index");
			return;
		}
		if(index===3){
			 this.$tab.navigateTo("/pages/quality/reportQuality/index");
			return;
		}
		//生产领料
		if(index===4){
			 this.$tab.navigateTo("/pages/warehouse/proPick/index");
			return;
		}
		//完工入库
		if(index===5){
			 this.$tab.navigateTo("/pages/warehouse/manufactureInto/index");
			return;
		}
		//即时库存
		if(index===6){
			 this.$tab.navigateTo("/pages/warehouse/inventory/index");
			return;
		}
		//工资单
		if(index===7){
			 this.$tab.navigateTo("/pages/finance/payroll/index");
			return;
		}
        this.$modal.showToast('模块建设中~')
      },
	  getExecuteBillCount(){
		  executeBillCount(this.queryParams).then( res=>{
			  this.data=res.data;
			  
		  })
	  },
	  initQueryParams(){
		  const end = new Date()
		  const start = new Date()
		  end.setDate(start.getDate()+1)
		this.queryParams.beginDate = start.format("yyyy-MM-dd");
		this.queryParams.endDate = end.format("yyyy-MM-dd")
		  
	  }
    }
  }
</script>

<style lang="scss">
  /* #ifndef APP-NVUE */
  page {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    background-color: #fff;
    min-height: 100%;
    height: auto;
  }
  /* #endif */
  /* #ifndef H5 */
	page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		background-color: #fff;
		min-height: 100%;
		height: auto;
	}
  /* #endif  */
  .text {
    text-align: center;
    font-size: 26rpx;
    margin-top: 10rpx;
  }

  .grid-item-box {
    flex: 1;
    /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
	/* #ifndef H5 */
		display: flex;
	/* #endif  */
	
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px 0;
  }

  .uni-margin-wrap {
    width: 690rpx;
    width: 100%;
    ;
  }
  
  .resourceList-uni-row {
  	margin-bottom: 8px;
  }
  
</style>
